/*
               File: C39
        Description: Conversion for table MMCLI30
             Author: GeneXus Java Generator version 8_0_9-040
       Generated on: 28 de Setiembre de 2010 13:0:29.24
       Program type: Callable routine
          Main DBMS: sqlserver
*/
import java.sql.*;
import com.genexus.db.*;
import com.genexus.*;
import com.genexus.distributed.*;

public final class c39 extends GXProcedure
{
   public c39( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( c39.class ), "" );
   }

   public c39( int remoteHandle ,
               ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( )
   {
      execute_int();
   }

   private void execute_int( )
   {
      initialize();
      /* GeneXus formulas */
      /* Output device settings */
      /* Using cursor C392 */
      pr_default.execute(0);
      while ( (pr_default.getStatus(0) != 101) )
      {
         A460VehFlg = C392_A460VehFlg[0] ;
         A459VehTip = C392_A459VehTip[0] ;
         A458VehCnt = C392_A458VehCnt[0] ;
         A457VehTip = C392_A457VehTip[0] ;
         A456VehNro = C392_A456VehNro[0] ;
         A455VehNro = C392_A455VehNro[0] ;
         A454VehNro = C392_A454VehNro[0] ;
         A453VehNro = C392_A453VehNro[0] ;
         A385ModCod = C392_A385ModCod[0] ;
         A189MarCod = C392_A189MarCod[0] ;
         A376TipAut = C392_A376TipAut[0] ;
         A417PrsVeh = C392_A417PrsVeh[0] ;
         A445CliCod = C392_A445CliCod[0] ;
         A35PrsCod = C392_A35PrsCod[0] ;
         /*
            INSERT RECORD ON TABLE GXA0039

         */
         AV2PrsCod = A35PrsCod ;
         AV3CliCod = A445CliCod ;
         AV4PrsVehC = A417PrsVeh ;
         if ( C392_n376TipAut[0] )
         {
            AV5TipAutC = 0 ;
         }
         else
         {
            AV5TipAutC = A376TipAut ;
         }
         if ( C392_n189MarCod[0] )
         {
            AV6MarCod = "" ;
         }
         else
         {
            AV6MarCod = A189MarCod ;
         }
         if ( C392_n385ModCod[0] )
         {
            AV7ModCod = "" ;
         }
         else
         {
            AV7ModCod = GXutil.str( A385ModCod, 4, 0) ;
         }
         if ( C392_n453VehNro[0] )
         {
            AV8VehNroP = "" ;
         }
         else
         {
            AV8VehNroP = A453VehNro ;
         }
         if ( C392_n454VehNro[0] )
         {
            AV9VehNroM = "" ;
         }
         else
         {
            AV9VehNroM = A454VehNro ;
         }
         if ( C392_n455VehNro[0] )
         {
            AV10VehNro = "" ;
         }
         else
         {
            AV10VehNro = A455VehNro ;
         }
         if ( C392_n456VehNro[0] )
         {
            AV11VehNro = "" ;
         }
         else
         {
            AV11VehNro = A456VehNro ;
         }
         if ( C392_n457VehTip[0] )
         {
            AV12VehTip = "" ;
         }
         else
         {
            AV12VehTip = A457VehTip ;
         }
         if ( C392_n458VehCnt[0] )
         {
            AV13VehCnt = "" ;
         }
         else
         {
            AV13VehCnt = A458VehCnt ;
         }
         if ( C392_n459VehTip[0] )
         {
            AV14VehTip = "" ;
         }
         else
         {
            AV14VehTip = A459VehTip ;
         }
         if ( C392_n460VehFlg[0] )
         {
            AV15VehFlg = "" ;
         }
         else
         {
            AV15VehFlg = A460VehFlg ;
         }
         /* Using cursor C393 */
         pr_default.execute(1, new Object[] {AV2PrsCod, new Short(AV3CliCod), new Short(AV4PrsVehC), new Byte(AV5TipAutC), AV6MarCod, AV7ModCod, AV8VehNroP, AV9VehNroM, AV10VehNro, AV11VehNro, AV12VehTip, AV13VehCnt, AV14VehTip, AV15VehFlg});
         if ( (pr_default.getStatus(1) == 1) )
         {
            Gx_err = (short)(1) ;
            Gx_emsg = localUtil.getMessages().getMessage("noupdate") ;
         }
         else
         {
            Gx_err = 0 ;
            Gx_emsg = "" ;
         }
         /* End Insert */
         pr_default.readNext(0);
      }
      pr_default.close(0);
      cleanup();
   }

   protected void cleanup( )
   {
      exitApplication();
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      C392_A460VehFlg = new String[] {""} ;
      C392_A459VehTip = new String[] {""} ;
      C392_A458VehCnt = new String[] {""} ;
      C392_A457VehTip = new String[] {""} ;
      C392_A456VehNro = new String[] {""} ;
      C392_A455VehNro = new String[] {""} ;
      C392_A454VehNro = new String[] {""} ;
      C392_A453VehNro = new String[] {""} ;
      C392_A385ModCod = new short[1] ;
      C392_A189MarCod = new String[] {""} ;
      C392_A376TipAut = new byte[1] ;
      C392_A417PrsVeh = new short[1] ;
      C392_A445CliCod = new short[1] ;
      C392_A35PrsCod = new String[] {""} ;
      A460VehFlg = "" ;
      A459VehTip = "" ;
      A458VehCnt = "" ;
      A457VehTip = "" ;
      A456VehNro = "" ;
      A455VehNro = "" ;
      A454VehNro = "" ;
      A453VehNro = "" ;
      A385ModCod = 0 ;
      A189MarCod = "" ;
      A376TipAut = 0 ;
      A417PrsVeh = 0 ;
      A445CliCod = 0 ;
      A35PrsCod = "" ;
      GIGXA0039 = 0 ;
      AV2PrsCod = "" ;
      AV3CliCod = 0 ;
      AV4PrsVehC = 0 ;
      C392_n376TipAut = new boolean[] {false} ;
      AV5TipAutC = 0 ;
      C392_n189MarCod = new boolean[] {false} ;
      AV6MarCod = "" ;
      C392_n385ModCod = new boolean[] {false} ;
      AV7ModCod = "" ;
      C392_n453VehNro = new boolean[] {false} ;
      AV8VehNroP = "" ;
      C392_n454VehNro = new boolean[] {false} ;
      AV9VehNroM = "" ;
      C392_n455VehNro = new boolean[] {false} ;
      AV10VehNro = "" ;
      C392_n456VehNro = new boolean[] {false} ;
      AV11VehNro = "" ;
      C392_n457VehTip = new boolean[] {false} ;
      AV12VehTip = "" ;
      C392_n458VehCnt = new boolean[] {false} ;
      AV13VehCnt = "" ;
      C392_n459VehTip = new boolean[] {false} ;
      AV14VehTip = "" ;
      C392_n460VehFlg = new boolean[] {false} ;
      AV15VehFlg = "" ;
      Gx_err = 0 ;
      Gx_emsg = "" ;
      pr_default = new DataStoreProvider(context, remoteHandle, new c39__default(),
         new Object[] {
             new Object[] {
            C392_A460VehFlg, C392_n460VehFlg, C392_A459VehTip, C392_n459VehTip, C392_A458VehCnt, C392_n458VehCnt, C392_A457VehTip, C392_n457VehTip, C392_A456VehNro, C392_n456VehNro,
            C392_A455VehNro, C392_n455VehNro, C392_A454VehNro, C392_n454VehNro, C392_A453VehNro, C392_n453VehNro, C392_A385ModCod, C392_n385ModCod, C392_A189MarCod, C392_n189MarCod,
            C392_A376TipAut, C392_n376TipAut, C392_A417PrsVeh, C392_A445CliCod, C392_A35PrsCod
            }
            , new Object[] {
            }
         }
      );
      /* GeneXus formulas. */
      Gx_err = 0 ;
   }

   private byte A376TipAut ;
   private byte AV5TipAutC ;
   private short A385ModCod ;
   private short A417PrsVeh ;
   private short A445CliCod ;
   private short AV3CliCod ;
   private short AV4PrsVehC ;
   private short Gx_err ;
   private int GIGXA0039 ;
   private String A460VehFlg ;
   private String A459VehTip ;
   private String A458VehCnt ;
   private String A457VehTip ;
   private String A456VehNro ;
   private String A455VehNro ;
   private String A454VehNro ;
   private String A453VehNro ;
   private String A189MarCod ;
   private String A35PrsCod ;
   private String AV2PrsCod ;
   private String AV6MarCod ;
   private String AV7ModCod ;
   private String AV8VehNroP ;
   private String AV9VehNroM ;
   private String AV10VehNro ;
   private String AV11VehNro ;
   private String AV12VehTip ;
   private String AV13VehCnt ;
   private String AV14VehTip ;
   private String AV15VehFlg ;
   private String Gx_emsg ;
   private IDataStoreProvider pr_default ;
   private String[] C392_A460VehFlg ;
   private String[] C392_A459VehTip ;
   private String[] C392_A458VehCnt ;
   private String[] C392_A457VehTip ;
   private String[] C392_A456VehNro ;
   private String[] C392_A455VehNro ;
   private String[] C392_A454VehNro ;
   private String[] C392_A453VehNro ;
   private short[] C392_A385ModCod ;
   private String[] C392_A189MarCod ;
   private byte[] C392_A376TipAut ;
   private short[] C392_A417PrsVeh ;
   private short[] C392_A445CliCod ;
   private String[] C392_A35PrsCod ;
   private boolean[] C392_n376TipAut ;
   private boolean[] C392_n189MarCod ;
   private boolean[] C392_n385ModCod ;
   private boolean[] C392_n453VehNro ;
   private boolean[] C392_n454VehNro ;
   private boolean[] C392_n455VehNro ;
   private boolean[] C392_n456VehNro ;
   private boolean[] C392_n457VehTip ;
   private boolean[] C392_n458VehCnt ;
   private boolean[] C392_n459VehTip ;
   private boolean[] C392_n460VehFlg ;
}

final class c39__default extends DataStoreHelperBase implements ILocalDataStoreHelper
{
   public Cursor[] getCursors( )
   {
      return new Cursor[] {
          new ForEachCursor("C392", "SELECT [VehFlgDai], [VehTipCom], [VehCntKm], [VehTipCnv], [VehNroCha], [VehNroMotA], [VehNroMotX], [VehNroPla], [ModCod], [MarCod], [TipAutCod], [PrsVehCod], [CliCod], [PrsCod] FROM [MMCLI30] WITH (NOLOCK) ORDER BY [PrsCod], [CliCod], [PrsVehCod] ",false, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,false )
         ,new UpdateCursor("C393", "INSERT INTO [GXA0039] ([PrsCod], [CliCod], [PrsVehCod], [TipAutCod], [MarCod], [ModCod], [VehNroPla], [VehNroMotX], [VehNroMotA], [VehNroCha], [VehTipCnv], [VehCntKm], [VehTipCom], [VehFlgDai]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", GX_NOMASK + GX_MASKLOOPLOCK)
      };
   }

   public void getResults( int cursor ,
                           IFieldGetter rslt ,
                           Object[] buf ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               ((String[]) buf[0])[0] = rslt.getString(1, 1) ;
               ((boolean[]) buf[1])[0] = rslt.wasNull();
               ((String[]) buf[2])[0] = rslt.getString(2, 20) ;
               ((boolean[]) buf[3])[0] = rslt.wasNull();
               ((String[]) buf[4])[0] = rslt.getString(3, 20) ;
               ((boolean[]) buf[5])[0] = rslt.wasNull();
               ((String[]) buf[6])[0] = rslt.getString(4, 20) ;
               ((boolean[]) buf[7])[0] = rslt.wasNull();
               ((String[]) buf[8])[0] = rslt.getString(5, 20) ;
               ((boolean[]) buf[9])[0] = rslt.wasNull();
               ((String[]) buf[10])[0] = rslt.getString(6, 20) ;
               ((boolean[]) buf[11])[0] = rslt.wasNull();
               ((String[]) buf[12])[0] = rslt.getString(7, 20) ;
               ((boolean[]) buf[13])[0] = rslt.wasNull();
               ((String[]) buf[14])[0] = rslt.getString(8, 20) ;
               ((boolean[]) buf[15])[0] = rslt.wasNull();
               ((short[]) buf[16])[0] = rslt.getShort(9) ;
               ((boolean[]) buf[17])[0] = rslt.wasNull();
               ((String[]) buf[18])[0] = rslt.getString(10, 10) ;
               ((boolean[]) buf[19])[0] = rslt.wasNull();
               ((byte[]) buf[20])[0] = rslt.getByte(11) ;
               ((boolean[]) buf[21])[0] = rslt.wasNull();
               ((short[]) buf[22])[0] = rslt.getShort(12) ;
               ((short[]) buf[23])[0] = rslt.getShort(13) ;
               ((String[]) buf[24])[0] = rslt.getString(14, 10) ;
               break;
      }
   }

   public void setParameters( int cursor ,
                              IFieldSetter stmt ,
                              Object[] parms ) throws SQLException
   {
      switch ( cursor )
      {
            case 1 :
               stmt.setString(1, (String)parms[0], 10);
               stmt.setShort(2, ((Short) parms[1]).shortValue());
               stmt.setShort(3, ((Short) parms[2]).shortValue());
               stmt.setByte(4, ((Byte) parms[3]).byteValue());
               stmt.setString(5, (String)parms[4], 10);
               stmt.setString(6, (String)parms[5], 10);
               stmt.setString(7, (String)parms[6], 20);
               stmt.setString(8, (String)parms[7], 20);
               stmt.setString(9, (String)parms[8], 20);
               stmt.setString(10, (String)parms[9], 20);
               stmt.setString(11, (String)parms[10], 20);
               stmt.setString(12, (String)parms[11], 20);
               stmt.setString(13, (String)parms[12], 20);
               stmt.setString(14, (String)parms[13], 1);
               break;
      }
   }

}

